<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Exception
 *
 * @author luigi.pastore
 * @created  14-apr-2011
 */
class Classes_Core_Exceptions extends Exception
{
    function exception( Exception $exception )
    {
	echo "Uncaught exception: ", $exception->getMessage(), "\n";
        echo "<pre>";
        print_r( debug_backtrace() );
        echo "</pre>";
        exit;
	
    }
    
    function error( $errno, $errstr, $errfile, $errline )
    {
	if( !(error_reporting() & $errno) )
	{
	    // This error code is not included in error_reporting
	    return;
	}

	switch( $errno )
	{
	    case E_USER_ERROR:
		echo "<b>My ERROR</b> [$errno] $errstr<br />\n";
		echo "  Fatal error on line $errline in file $errfile";
		echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
		echo "Aborting...<br />\n";
                echo "<pre>";
                var_dump( debug_backtrace() );
                echo "</pre>";
		exit( 1 );
		break;

	    case E_USER_WARNING:
		echo "<b>My WARNING</b> [$errno] $errstr<br />\n";
		break;

	    case E_USER_NOTICE:
		echo "<b>My NOTICE</b> [$errno] $errstr<br />\n";
		break;

	    case E_USER_WARNING:
		echo "<b>My Warning</b> [$errno] $errstr<br />\n";
		break;
	    
	    default:
		echo "<b>My ERROR</b> [$errno] $errstr<br />\n";
		echo "  Fatal error on line $errline in file $errfile";
		echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
		echo "Aborting...<br />\n";
                echo "<pre>";
                var_dump( debug_backtrace() );
                echo "</pre>";                
		exit( 1 );
		break;
	}

	// Ripulisci Buffer
	//ob_end_clean();

	/* Don't execute PHP internal error handler */
	return true;
    }

}

?>
